package com.shujia.day14;

import java.util.ArrayList;
import java.util.Random;

/*
    获取10个1-20之间的随机数，要求不能重复
 */
public class ListTest1 {
    public static void main(String[] args) {
        Random random = new Random();
//        int number = random.nextInt(20) + 1;
//        System.out.println(number);

        ArrayList<Integer> list1 = new ArrayList<>();
        while (list1.size() < 10) {
            int number = random.nextInt(20) + 1;
            if (!list1.contains(number)) {
                list1.add(number);
            }
        }

        System.out.println("list1: " + list1);
    }
}
